package com.mediacloud.app.newsmodule.activity

import android.graphics.Color
import android.os.Bundle
import androidx.recyclerview.widget.LinearLayoutManager
import com.mediacloud.app.model.activity.BaseBackActivity
import com.mediacloud.app.newsmodule.R
import com.mediacloud.app.newsmodule.adaptor.MagazineIntroduceAdapter
import com.mediacloud.app.newsmodule.model.MagazineProgramBean
import kotlinx.android.synthetic.main.activity_magazine_introduce_layout.*

class MagazineIntroduceActivity : BaseBackActivity() {

    override fun getLayoutResID(): Int {
        return R.layout.activity_magazine_introduce_layout
    }
    var data : MagazineProgramBean.IntroFieldDtoData ?= null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        top.setBackgroundColor(Color.WHITE)
        if(intent.getSerializableExtra("data")!=null){
            data = intent.getSerializableExtra("data") as MagazineProgramBean.IntroFieldDtoData
        }
        introduceList.layoutManager = LinearLayoutManager(this,LinearLayoutManager.VERTICAL,false)
        val magazineIntroduceAdapter = MagazineIntroduceAdapter()
        introduceList.adapter = magazineIntroduceAdapter
        data?.let {
            val childFields = it.childFields
            if(childFields.size>0){
                magazineIntroduceAdapter.setNewData(childFields)
            }else{
                showStateView(TYPE_NO_CONTENT, false)
            }
        }

    }
}